/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tesauro;

/**
 *
 * @author demian
 */
public class ELFStringHashCode implements IHashCodeStrategy {
    public int hash(String palabra) {
        long hash = 0;
        long x    = 0;

        for(int i = 0; i < palabra.length(); i++)
        {
            hash = (hash << 4) + palabra.charAt(i);

            if((x = hash & 0xF0000000L) != 0)
            {
                hash ^= (x >> 24);
            }
            hash &= ~x;
        }

        return (int)hash;
    }
}
